//Thursday, November 05 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}
#define 	inf		 100000001
class HamiltonPath
{
public:
	int countPaths(vector <string> roads)
	{
		int ret = 0;
		int count = 0;
//		vector<vector<int> > v(roads.size(), vector<int>(roads[0].size(), inf));
 		for(int i=0; i<roads.size(); i++)
 		{
 			for(int j=0; j<roads[0].size(); j++)
 			{
 				if(roads[i][j]=='Y')
 					count++;
 			}
 		}
		vector<int> path;
		for(int i=0; i<roads.size(); i++)
			path.push_back(i);
		do
		{
			int cnt = 0;
			for(int i=1; i<roads.size(); i++)
				if(roads[path[i-1]][path[i]] == 'Y')
				{
					cnt++;
				}
			if(cnt*2 == count) ret++;
			ret = ret%1000000007;
		}
		while(next_permutation(path.begin(), path.end()));
		return ret;
	}
};